package task

import (
	"gitee.com/cdsailyj/go-vpn/global"
	"github.com/robfig/cron/v3"
	"log"
)

func StartCron() {
	go func() {
		var option []cron.Option
		option = append(option, cron.WithSeconds())
		// 清理DB定时任务
		_, err := global.Timer.AddTaskByFunc("ClearDB", "@every 1h", func() {
			log.Printf("定时任务1在执行: \n")
		}, "定时1", option...)
		if err != nil {
			log.Printf("定时任务1添加失败: %v \n", err)
		}

		//_, err := global.GVA_Timer.AddTaskByFunc("定时任务标识", "corn表达式", func() {
		//	具体执行内容...
		//  ......
		//}, option...)
		//if err != nil {
		//	fmt.Println("add timer error:", err)
		//}
	}()
}
